package com.ruoyi.web.controller.memberCoupon;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TablePassCardManagement;
import com.ruoyi.system.service.ITablePassCardManagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 桌台次卡管理 Controller
 *
 * @author ruoyi
 * @date 2025-05-21
 */
@Api(tags="桌台次卡管理")
@RestController
@RequestMapping("/system/tablePassCardManagement")
public class TablePassCardManagementController extends BaseController
{
    @Autowired
    private ITablePassCardManagementService tablePassCardManagementService;

    /**
     * 通过条件查询桌台次卡管理列表
     */
    @ApiOperation("通过条件查询桌台次卡管理列表")
    @PreAuthorize("@ss.hasPermi('system:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String passCardName,@RequestParam(required = false) String status)
    {
        startPage();
        List<TablePassCardManagement> list = tablePassCardManagementService.selectTablePassCardManagementListByConditions(passCardName,status);
        return getDataTable(list);
    }

    /**
     * 导出桌台次卡管理列表
     */
    @ApiOperation("导出桌台次卡管理列表")
    @PreAuthorize("@ss.hasPermi('system:management:export')")
    @Log(title = "桌台次卡管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam(required = false) String passCardName,@RequestParam(required = false) String status)
    {
        List<TablePassCardManagement> list = tablePassCardManagementService.selectTablePassCardManagementListByConditions(passCardName,status);
        ExcelUtil<TablePassCardManagement> util = new ExcelUtil<TablePassCardManagement>(TablePassCardManagement.class);
        util.exportExcel(response, list, "桌台次卡管理数据");
    }

    /**
     * 通过id获取桌台次卡管理信息
     */
    @ApiOperation("通过id获取桌台次卡管理信息")
    @PreAuthorize("@ss.hasPermi('system:management:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tablePassCardManagementService.selectTablePassCardManagementById(id));
    }

    /**
     * 新增桌台次卡管理
     */
    @ApiOperation("新增桌台次卡管理")
    @PreAuthorize("@ss.hasPermi('system:management:add')")
    @Log(title = "桌台次卡管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TablePassCardManagement tablePassCardManagement)
    {
        return toAjax(tablePassCardManagementService.insertTablePassCardManagement(tablePassCardManagement));
    }

    /**
     * 修改桌台次卡管理
     */
    @ApiOperation("修改桌台次卡管理")
    @PreAuthorize("@ss.hasPermi('system:management:edit')")
    @Log(title = "桌台次卡管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TablePassCardManagement tablePassCardManagement)
    {
        return toAjax(tablePassCardManagementService.updateTablePassCardManagement(tablePassCardManagement));
    }

    /**
     * 通过id批量删除桌台次卡管理信息
     */
    @ApiOperation("通过id批量删除桌台次卡管理信息")
    @PreAuthorize("@ss.hasPermi('system:management:remove')")
    @Log(title = "桌台次卡管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tablePassCardManagementService.deleteTablePassCardManagementByIds(ids));
    }
}
